<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}

			div#search {
				width: 430px;
				margin: 0px auto;
				border: 1px solid red;
			}

			div#search img {
				vertical-align: middle;
			}

			div#search span {
				display: inline-block;
				border: 1px solid #2EA0F0;
				background-color: #2EA0F0;
				height: 25px;

			}

			div#search span input {
				height: 25px;
				width: 250px;
				border: none;
				outline: none;
			}

			div#search>input:first-of-type {
				margin-left: 90px;
			}
		</style>

		<script type="text/javascript">
			function change() {
				var img = document.getElementsByName("img");
				var i;
				for (var i of img) {
					if (i.checked) {
						break;
					}
				}
				var f = document.getElementById("search");
				var e=document.getElementById("a");
				var s = i.value;
				if (s == "taobao") {
					f.firstElementChild.src = "images/taobao_shopping-446.png";
					a.action="https://www.taobao.com";
				} else if (s == "baidu") {
					f.firstElementChild.src = "images/baidu_web.png";
					a.action="https://www.baidu.com";
				} else {
					f.firstElementChild.src = "images/google_web-444.png";
					a.action="http://www.google.cn/";
				}
			}

			// function change2() {
			// 	alert("原先的地址" + document.forms['form1'].action );
			// 	document.forms['form1'].action = "https://www.baidu.com"; //在这就可以改变表单的提交地址
			// 	alert("改变后的地址" + document.forms['form1'].action );
			// 	Submit();
			// }
		</script>
	</head>
	<body>
		<div id="search">
			<img src="images/taobao_shopping-446.png" /><span>
				<form name="form1" action="" method="post" id="a"/>
				<input type="text" id="" value="" />
				<input type="submit" id="" name="" value="搜索" />
				</form>
			</span>
			<input type="radio" name="img" value="baidu" onclick="change()" />百度
			<input type="radio" name="img" value="google" onclick="change()" />谷歌
			<input type="radio" name="img" value="taobao" onclick="change()" checked="checked" />淘宝
		</div>
	</body>
</html>
